package com.job.client.common.rabbitmqConfig;

import com.job.client.model.rabbitmq.AuditConstant;
import com.job.client.model.rabbitmq.AuditResultConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
/*
 * 审核结果rabbitmq配置
 * */
public class RabbitmqAuditResultConfig {
    @Bean
    public Exchange EXCHANGE_AUDIT_RESULT(){
        return ExchangeBuilder
                .directExchange(AuditResultConstant.EXCHANGE_AUDIT_RESULT) // 直连交换机，根据key匹配
                .durable(true).build();  // 持久化
    }
    @Bean
    public Queue QUEUE_AUDIT_AVATAR_RESULT(){
        return new Queue(AuditResultConstant.QUEUE_AUDIT_AVATAR_RESULT);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_AVATAR_RESULT
            (Queue QUEUE_AUDIT_AVATAR_RESULT, Exchange EXCHANGE_AUDIT_RESULT){
        return BindingBuilder.bind(QUEUE_AUDIT_AVATAR_RESULT)
                .to(EXCHANGE_AUDIT_RESULT)
                .with(AuditResultConstant.ROUTINGKEY_AVATAR_RESUT).noargs();
    }
    @Bean
    public Queue QUEUE_AUDIT_COMPANY_RESULT(){
        return new Queue(AuditResultConstant.QUEUE_AUDIT_COMPANY_RESULT);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_COMPANY_RESULT
            (Queue QUEUE_AUDIT_COMPANY_RESULT, Exchange EXCHANGE_AUDIT_RESULT){
        return BindingBuilder.bind(QUEUE_AUDIT_COMPANY_RESULT)
                .to(EXCHANGE_AUDIT_RESULT)
                .with(AuditResultConstant.ROUTINGKEY_COMPANY_RESUT).noargs();
    }
    @Bean
    public Queue QUEUE_AUDIT_POSTS_RESULT(){
        return new Queue(AuditResultConstant.QUEUE_AUDIT_POSTS_RESULT);
    }
    @Bean
    public Binding BINDING_QUEUE_AUDIT_POSTS_RESULT
            (Queue QUEUE_AUDIT_POSTS_RESULT, Exchange EXCHANGE_AUDIT_RESULT){
        return BindingBuilder.bind(QUEUE_AUDIT_POSTS_RESULT)
                .to(EXCHANGE_AUDIT_RESULT)
                .with(AuditResultConstant.ROUTINGKEY_POSTS_RESUT).noargs();
    }
}
